package org.mendoza.salud.hvt.server.listeners;


import org.mendoza.salud.hvt.client.shared.model.AbstractEntity;
import org.mendoza.salud.hvt.client.shared.util.UUID;

import javax.persistence.EntityListeners;
import javax.persistence.PrePersist;


/**
 * Created with IntelliJ IDEA.
 * User: Ricardo
 * Date: 06/11/13
 * Time: 10:32
 * To change this template use File | Settings | File Templates.
 */
@EntityListeners(value = {AbstractEntityListener.class})
public class AbstractEntityListener {
    @PrePersist
    public void onPrePersist(AbstractEntity abstractEntity) {
        if (abstractEntity.getAeuid() == null) {
            abstractEntity.setAeuid(UUID.uuid());
        }
    }

}
